import * as data from './data';
import log from '../../../log';
import * as utils from '../../../util/';

export function get(page, pagesize) {
    return utils.resolve().then(() => {
        log.info('get feedBack page---', page);
        log.info('get feedBack pagesize---', pagesize);
        return data.get(pagesize, page).then(res => {
            log.info('get feedBack resule---', utils.data(res, 1));
            return utils.data(res, 1);
        });
    }).catch(err => {
        log.error('get feedBack is err', err);
        return err;
    });
}
export function add(feed) {
    return utils.resolve().then(() => {
        log.info('add feedBack para---', feed);
        feed.id = utils.uuid();
        return data.add(feed).then(res => {
            log.info('add feedBack resule---', utils.data(res));
            return utils.data(res);
        });
    }).catch(err => {
        log.error('addFeedBack is err', err);
        return err;
    });
}
export function edit(feedBack) {
    return utils.resolve().then(() => {
        log.info('edit feedBack para---', feedBack);
        return data.edit(feedBack).then(res => {
            log.info('edit feedBack resule---', utils.data(res));
            return utils.data(res);
        });
    }).catch(err => {
        log.error('edit feedBack is err', err);
        return err;
    });
}
export function del(id) {
    return data.del(id).then(res => {
        log.info('delete feedBack result ---', res.toJSON());
        return utils.data(res);
    }).catch(err => {
        log.error('del feedBack is err', err.message || err);
        return err;
    });
}
